@import './button.component';

:host ::ng-deep .devui-btn-group {
  display: flex;

  & > * {
    position: relative;

    &:not(:first-child) {
      .devui-dropdown-toggle:not(d-button),
      .devui-btn {
        border-top-left-radius: 0;
        border-bottom-left-radius: 0;
        margin-left: -1px;

        &.devui-btn-primary {
          margin-left: 0;
        }
      }

      .devui-dropdown-menu {
        left: -1px;
      }
    }

    &:not(:last-child) {
      .devui-dropdown-toggle,
      .devui-btn {
        border-top-right-radius: 0;
        border-bottom-right-radius: 0;
      }
    }

    .devui-dropdown-origin {
      z-index: 0;
    }

    &:hover,
    &:active {
      z-index: 1;
    }

    &:focus-within {
      z-index: 1;
    }
  }
}

:host ::ng-deep {
  @each $type in xs, sm, lg {
    .devui-btn-group-#{$type} {
      .devui-btn {
        @extend .devui-btn-#{$type};
      }
    }
  }
}

:host ::ng-deep {
  d-button + d-button {
    .devui-btn-primary:not(:disabled)::before,
    .devui-btn-common:not(:disabled)::before,
    .devui-btn-danger:not(:disabled)::before {
      content: '';
      position: absolute;
      top: 0;
      bottom: 0;
      left: 0;
      width: 1px;
      background-color: rgba($color: $devui-white-5, $alpha: 0.2);
    }

    .devui-btn:disabled {
      border-left-style: none;
      margin-left: 0;
    }
  }

  d-button:active + d-button,
  d-button + d-button:active {
    .devui-btn-primary:not(:disabled)::before {
      background-color: $devui-primary-active;
    }

    .devui-btn-common:not(:disabled)::before {
      background-color: var(--devui-btn-common-bg-active, $devui-base-bg);
    }

    .devui-btn-danger:not(:disabled)::before {
      background-color: $devui-contrast-active;
    }
  }

  d-button:focus-within + d-button,
  d-button + d-button:focus-within,
  d-button:hover + d-button,
  d-button + d-button:hover {
    .devui-btn-primary:not(:disabled)::before {
      background-color: $devui-primary-hover;
    }

    .devui-btn-common:not(:disabled)::before {
      background-color: var(--devui-btn-common-border-color-hover, $devui-form-control-line-active);
    }

    .devui-btn-danger:not(:disabled)::before {
      background-color: $devui-contrast-hover;
    }
  }
}
